<?php 
$group = $_SESSION[CAMPAIGNDATA]->group;
?>
<style>
#ad-preview h2 {
-moz-background-clip:border;
-moz-background-inline-policy:continuous;
-moz-background-origin:padding;
background:#EEEEEE none repeat scroll 0 0;
color:#AAAAAA;
font-family:Verdana,Arial,Helvetica,sans-serif;
font-size:10px;
font-weight:normal;
margin:-18px -18px 15px;
padding:3px 18px;
text-transform:uppercase;
}
#ad-preview{
	border:2px dotted #CCCCCC;
	font-family:"Times New Roman",Times,serif;
	font-size:14px;
	margin-bottom:20px;
	overflow:hidden;
	padding:18px;
	position:relative;
	width:240px;"
}
.headline {
color:#0000FF;
cursor:pointer;
font-weight:bold;
text-decoration:underline;
}
.addName {
color:#0000FF;
cursor:pointer;
font-weight:bold;
text-decoration:underline;
}
.txtUrl{
color:#008000;
white-space:nowrap
}
.addUrl{
color:#008000;
white-space:nowrap
}
</style>
<?php 
	//$Result_Adgroup = mysql_fetch_array(mysql_query("SELECT network_type,network FROM adgroup where adgroup_id ={$_SESSION['CAMPAIGNDATA']->group_id}"));
	$sql_landing_page=mysql_query("select * from adspace_landing_page where UserId='".$_SESSION['siteuserId']."'");

if($group->network=='mobile')
{
?>	

<script language="JavaScript">
function selfclose()
{
//self.close();
parent.parent.GB_hide();
}
function IsNumeric(strString)
//check for valid numeric strings
{
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
	
	if (strString.length == 0) return false;
	
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}

function create_ad()
{
	if(document.myAccountForm.bid_price.value =="")
	{
		alert("Please enter Bid Price.");
		document.getElementById("bid_price").focus();
		return false;
	}else
	{
		number = document.myAccountForm.bid_price.value;
		if(!IsNumeric(number))
		{
			alert("Please Enter Numeric Value As Bid Price.");
			document.getElementById("bid_price").focus();
			return false;	
		}
	}
	if(document.myAccountForm.ad_name.value =="")
	{
		alert("Please Enter Ad Name.");
		document.getElementById("ad_name").focus();
		return false;
	}
	if(document.myAccountForm.ad_text.value =="" && document.myAccountForm.ad_type.value == 'text')
	{
		alert("Please Enter Ad Text.");
		document.getElementById("ad_text").focus();
		return false;
	}
	if(document.myAccountForm.destinationUrl.value =="")
	{
		alert("Please Enter The Link.");
		document.getElementById("destinationUrl").focus();
		return false;
	}
	document.myAccountForm.mode.value='create_advertise';
	document.myAccountForm.submit();
	return true;
}
function show_mobile_set(id)
{
	//alert(id);
	for(var i =1; i<=4;i++)
	{
// 		if(document.getElementById('content_'+i))
// 		{
			if(i == id)
			{
				//alert('aaa');
				document.getElementById('content_'+i).style.display = 'block';	
			}
			else
			{
				document.getElementById('content_'+i).style.display = 'none';	
			}

		//}
		
	}
	
}


jQuery('document').ready(function(){
	
	jQuery('select[name=ad_type]').each(function(){
		val = jQuery.trim(jQuery(this).find('option:selected').val());
		prew  = jQuery(this).parents('tr.mobile');
		if(val=="text"){
			prew.find('tr.ad-text').show();
			prew.find('tr.ad-images').hide();
			prew.find('tr.text_preview').show();
			prew.find('tr.preview').hide();
		}else{
			prew.find('tr.ad-images').show();
			prew.find('tr.ad-text').hide();
			prew.find('tr.text_preview').hide();
			prew.find('tr.preview').show();
		}
	});
	
	
	jQuery('input[name=ad_name]').die('keyup');
	jQuery('input[name=ad_name]').live('keyup',function(){
		val = jQuery(this).val();
		prew  = jQuery(this).parents('tr.mobile');
		prew.find('div.addName').text(val);
	});
	
	jQuery('textarea[name=ad_text]').die('keyup');
	jQuery('textarea[name=ad_text]').live('keyup',function(){
		val = jQuery(this).val();
		prew  = jQuery(this).parents('tr.mobile');
		prew.find('div.addTxt').text(val);
	});
	jQuery('input[name=destinationUrl]').die('keyup');
	jQuery('input[name=destinationUrl]').live('keyup',function(){
		val = jQuery(this).val();
		prew  = jQuery(this).parents('tr.mobile');
		prew.find('div.addUrl').text(val);
	});

	jQuery('select.admob-FormDropDownBox').die('change');
	jQuery('select.admob-FormDropDownBox').live('change',function(){
		val = jQuery(this).val();
		prew  = jQuery(this).parents('tr.mobile');
		if(val=="text"){
			prew.find('tr.ad-text').show();
			prew.find('tr.ad-images').hide();
			prew.find('tr.text_preview').show();
			prew.find('tr.preview').hide();
		}else{
			prew.find('tr.ad-images').show();
			prew.find('tr.ad-text').hide();
			prew.find('tr.text_preview').hide();
			prew.find('tr.preview').show();
		}
	});
});

</script>

	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-Height">
		<tr class="mobile">
			<td valign="top" style="padding:5px;">
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-Height">
					<tr>
						<td width="600" valign="top">
							<table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-Height">
								<tr>
									<td class="admob-SquareBoxTilteBg">Create Ad</td>
								</tr>
								<tr>
									<td valign="top" class="admob-SquareBoxBorder">
									<form name="create_campaign" method="POST" id="create_campaign" action=""  enctype="multipart/form-data">
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
	                     	
						                     	<td colspan="2"><br><?php if($message!="") echo $message;?></td>
						                     </tr>
											<tr>
												<td>
													<table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-FormContent">
														<tr>
															<td width="162" height="25">Select Ad Type :</td>
															<td>
																<select class="admob-FormDropDownBox" id="ad_type" name="ad_type" onchange="show_text_image()">
																	<option value="text">Text</option>
																	<option value="banner">Banner</option>
																</select>
															</td>
														</tr>
													</table>
												</td>
											</tr>
											
											<tr>
												<td>
													<table width="100%" border="0" cellspacing="0" cellpadding="0" id="adText_module">

														<tr>
															<td>
																<table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-FormContent">
																	<tr>
																		<td width="162" height="28">Enter Bid Price :</td>
																		<td><input name="bid_price" id="bid_price" maxlength="30" type="text" class="admob-InputBoxsmallest" /></td>
																	</tr>
																	<tr id="row_alert_adName" style="display: none">
																		<td width="162">&nbsp;</td>
																		<td align="left" id="error_adName" style="color: #FF0000; font-weight: bold; font-size: 11px;"></td>
																	</tr>
																	<tr>
																		<td height="28">Ad Name :</td>
																		<td><input name="ad_name" id="ad_name" maxlength="60" type="text" class="admob-FromInputBox" /></td>
																	</tr>
																	<tr id="row_alert_adText" style="display: none">
																		<td width="162">&nbsp;</td>
																		<td align="left" id="error_adText" style="color: #FF0000; font-weight: bold; font-size: 11px;"></td>
																	</tr>
																	<tr class="ad-text">
																		<td valign="top">Ad Text :</td>
																		<td valign="top"><textarea name="ad_text" class="admob-TextareaSmall" id="ad_text" rows="3" cols="35"></textarea><br />
																		<span class="admob-FormSmallContent">Use the %phn% tag to insert the user's phone modelinto the text<br /> of your ad. (35 char max)</span></td>
																	</tr>
																	<tr class="admob-FormContent" id="link_url_existing_div">
																		<td height="28">Destination URL :</td>
																		<td><input name="destinationUrl" id="destinationUrl" type="text" class="admob-FromInputBox" /></td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
											<tr class="ad-images" >
												<td>
													<table width="100%" border="0" cellspacing="0" cellpadding="0" id="image_section" >
														<tr><td colspan="2" height="5">&nbsp;</td></tr>
														<tr>
															<td colspan="2" width="162" valign="top" ><strong>Image (optional) :</strong></td>
														</tr>
														<tr>
															<td valign="top" >
																<table width="100%" border="0" cellspacing="0" cellpadding="0">
																	<tr><td colspan="2" height="10">&nbsp;</td></tr>
																	<tr>
																		<td valign="top" >
																			<table width="100%" border="0" cellspacing="0" cellpadding="0">
																				<tr>
																					<td height="20" class="admob-BlueBoldContent">Upload new
																					Image</td>
																				</tr>
																				<tr>
																					<td bgcolor="#f8f9fb">
																						<table width="100%" border="0" cellspacing="0" cellpadding="0">
																							<tr>
																								<td class="admob-FormBorder">
																									<table width="100%" border="0" cellpadding="0" cellspacing="0">
																										<tr>
																											<td>
																												<table width="100%" border="0" cellspacing="0" cellpadding="0">
																													<tr>
																														<td><input name="MAX_FILE_SIZE" value="75000" type="hidden"> <span id="fileInput"> 
																															<iframe src="upload.php" align="top" frameborder="0" scrolling="no" width="390px" height="110px" allowtransparency="true"></iframe> </span> 
																															<inpUT type="hidden" name="sahara" value="11"> 
																														</td>
																													</tr>
																												</table>
																											</td>
																										</tr>
																										<tr>
																											<td height="20" class="admob-FormSmallContent">(Allowed
																											filetypes: *.jpg, *.jpeg, *.png) Upload size:(150 X
																											100)px</td>
																										</tr>
																									</table>
																								</td>
																							</tr>
																						</table>
																					</td>
																				</tr>
																				<tr>
																					<td><img src="images/spacer.gif" alt="" width="10"
																						height="7" /></td>
																				</tr>
																				<tr>
																					<td>
																						<table width="100%" border="0" cellspacing="0" cellpadding="0">
																							<tr>
																								<td class="admob-FormBorder">
																									<table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-BlueBoldContent" id="imageSections">
																										<tr>
																											<td height="20">XL - 300x50</td>
																										</tr>
																										<tr>
																											<td><img src="images/admob-300x50img.jpg" alt=""
																												width="300" height="50" id="xl_img" /><input
																												name="xl_image_url" id="xl_image_url"
																												class="image_url" type="hidden"></td>
																										</tr>
																										<tr>
																											<td height="20">Large - 216x36</td>
																										</tr>
																										<tr>
																											<td><img id="l_img" src="images/admob-216x36img.jpg"
																												alt="" width="216" height="36" /><input
																												name="l_image_url" id="l_image_url" class="image_url"
																												type="hidden"></td>
																										</tr>
																										<tr>
																											<td height="20">Medium - 168x28</td>
																										</tr>
																										<tr>
																											<td><img id="m_img" src="images/admob-168x28img.jpg"
																												alt="" width="168" height="28" /> <input
																												name="m_image_url" id="m_image_url" class="image_url"
																												type="hidden"></td>
																										</tr>
																										<tr>
																											<td height="20">Small - 120x20</td>
																										</tr>
																										<tr>
																											<td><img id="s_img" src="images/admob-120x20img.jpg"
																												alt="" width="120" height="20" /><input
																												name="s_image_url" id="s_image_url" class="image_url"
																												type="hidden"></td>
																										</tr>
																									</table>
																								</td>
																							</tr>
																						</table>
																					</td>
																				</tr>
																			</table>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
													
												</td>
											</tr>
											<tr><td colspan="2" height="5">&nbsp;</td></tr>
											<tr>
												<td  valign="top"  colspan="2"><strong>Select
															Targeting Country :</strong></td>
											</tr>
											<tr>
												
												<td style="padding-left:40px;padding-top:20px;">
													<table width="100%" border="0" cellspacing="0" cellpadding="0">
														<tr>
														<?php
														$SQL_country="select * from country";
														$EXE_country=mysql_query($SQL_country);
														?>
															
															<td valign="top" colspan="2"><select class="admob-LargeTextfield"
																name="country_mobile[]" id="country_mobile" multiple="true">
																<option value="" selected="selected">Select Country</option>
																<?php
																while($ROW_country=mysql_fetch_array($EXE_country))
																{
																	?>
																<option
																	value="<?php echo $ROW_country[countries_iso_code_2]; ?>"><?php echo $ROW_country[countryName]?></option>
																	<?php
																}
																?>
															</select></td>
														</tr>
													</table>
												</td>
											</tr>
											
											<tr>
												<td>&nbsp;</td>
											</tr>
											<tr>
												<td align="center">
												<input type="hidden" name="type" value="<?php echo $group->network; ?>">
												<input id="create_ad_submit" name="submit" type="submit"  value="Save" ></td>
											</tr>
											
										</table>
									</td>
								</tr>
								
							</table>
						</td>
						<td width="11" valign="top">&nbsp;</td>
						<td width="302" valign="top">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr class="text_preview">
									<td>
										<table width="100%" border="0" cellspacing="0" cellpadding="0" id="text_preview">
											<tr>
												<td valign="top">
														<div style="float:left;position:relative;top:0;width:280px;">
					                              		<div id="ad-preview">
					                              			<h2>Ad Preview</h2>
		                              						<div class="addName" style="width:100%;">This is a sample headline</div>
								                            <div  class="addTxt" style="width:100%;">This is sample text. You get seventy characters. Have fun with them :)</div>
								                            <div class="addUrl" style="width:100%;">www.Sample-Site.com</div>
						                              	</div>
					                              	</div>
												</td>
											</tr>
											<tr>
												<td align="center" id="preview_text_description"></td>
											</tr>
										
										</table>
									</td>
								</tr>
								<tr class="preview">
									<td>
									<table width="100%" border="0" cellspacing="0" cellpadding="0" id="preview" >
										<tr>
											<td>
												<table width="100%" border="0" cellspacing="0" cellpadding="0">
													<tr>
														<td>
															<table border="0" cellspacing="0" cellpadding="0">
																<tr>
																	<td width="29" id="Nav1" onclick="show_mobile_set(1)"><img
																		src="images/admob-SButton.jpg" alt="" width="29"
																		height="22" /></td>
																	<td width="3">&nbsp;</td>
																	<td width="29" id="Nav2" onclick="show_mobile_set(2)"><img
																		src="images/admob-MButton.jpg" alt="" width="29"
																		height="22" /></td>
																	<td width="3">&nbsp;</td>
																	<td width="29" id="Nav3" onclick="show_mobile_set(3)"><img
																		src="images/admob-LButton.jpg" alt="" width="29"
																		height="22" /></td>
																	<td width="3">&nbsp;</td>
																	<td width="29" id="Nav4" onclick="show_mobile_set(4)"><img
																		src="images/admob-XLButton.jpg" alt="" width="29"
																		height="22" /></td>
																</tr>
															</table>
														</td>
													</tr>
													<tr>
														<td><img src="images/spacer.gif" alt="" width="10" height="8" /></td>
													</tr>
													<tr>
														<td><img src="images/admob-300x50img.jpg" alt="" width="300"
															height="50" /></td>
													</tr>
													<tr>
														<td><img src="images/spacer.gif" alt="" width="10" height="8" /></td>
													</tr>
												</table>
											</td>
										</tr>
										<tr class="preview_content selected" id="content_1"
											style="display: block; width: 120; height: 20">
											<td class="admob-FormContent"><strong>Mobile Website</strong><br />
											</td>
										</tr>
										<tr class="preview_content" id="content_2"
											style="display: none; width: 168; height: 28;">
											<TD class="admob-FormContent"><strong>Mobile Website</strong><br />
											</TD>
										</tr>
										<tr class="preview_content" id="content_3"
											style="display: none; width: 216; height: 36;">
											<TD class="admob-FormContent"><strong>Mobile Website</strong><br />
											</TD>
										</tr>
										<tr class="preview_content" id="content_4"
											style="display: none; width: 300; height: 50;">
											<TD class="admob-FormContent"><strong>Mobile Website</strong><br />
											</TD>
										</tr>
										 <tr>
                           		<td height="50">&nbsp;</td>
                           </tr>
                          
									</table>
									
								</td>
							</tr>
							
						</table>
						</form>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	 <tr>
	  	<td colspan="3" style="padding-left:10px;"><br><br>
	  		<form name="create_campaign" method="POST" id="create_campaign" action=""  enctype="multipart/form-data">
  		
  		
  		<?php 
		$query =mysql_query("Select * FROM temp_adgroup_ad where siteuserId={$_SESSION[siteuserId]}");
		$i=1;
		if(mysql_num_rows($query)>0)
		{
			echo '<table  id="myTable"  width="600px" border="1"><tbody>
  		<tr>
  			<th><input type="checkbox" id="group" name="group" onclick="Checkall();"></th>
  			<th style="font-family:Time new roman;font-size:12px;">Ad headline</th>
  			<th style="font-family:Time new roman;font-size:12px;">Destination URL</th>
  		</tr>';
			
			while($result= mysql_fetch_array($query)){
				echo '<tr>
						<td width="20" align="center" ><input type="checkbox" id="ad_group_id" name="ad_group_id[]" value='.$result['id'].'></td>
						
						<td width="200" >'.$result['personal_reference'].'</td>
						<td  >'.$result['dest_url'].'</td>

					</tr>'; 
				$i++;
			}
			echo '</tbody></table> ';
		}
		?>
		
		<br><br>
		  <table border="0" cellpadding="0" cellspacing="0" width="100%">
		  	<tr>
		  		<td align="center">
		  		<input type="submit" name="submit" value="Next">
                           		<input type="hidden" name="mode" value="step3">
		  		</td>
		  	</tr>
		  </table>		
		  </form>
			  		
	  	</td>
	  </tr>
	  
</table>
</form>
<?php 	
}else{	
	//print_r($data->campaign->network_type);
?>


<script>
function showhidSelectBox(mode)
{
	if(mode!='none')
	{
		document.getElementById('txtUrl').value=document.getElementById('selExistingAd').value;
	}
	else
	{
		document.getElementById('txtUrl').value='';
		document.getElementById('txtUrl').readOnly=false;
	}
	document.getElementById('tdExistingAd').style.display=mode;
}

jQuery('document').ready(function(){
	jQuery('input[name=txtHeadline]').die('keyup');
	jQuery('input[name=txtHeadline]').live('keyup',function(){
		val = jQuery(this).val();
		prew  = jQuery(this).parents('tr.add-Group');
		prew.find('div.headline').text(val);
	});
	jQuery('textarea[name=text_description]').die('keyup');
	jQuery('textarea[name=text_description]').live('keyup',function(){
		val = jQuery(this).val();
		prew  = jQuery(this).parents('tr.add-Group');
		prew.find('div.adDesc').text(val);
	});
	jQuery('input[name=txtUrl]').die('keyup');
	jQuery('input[name=txtUrl]').live('keyup',function(){
		val = jQuery(this).val();
		prew  = jQuery(this).parents('tr.add-Group');
		prew.find('div.txtUrl').text(val);
	});
	jQuery('input[name=txtAdName]').die('keyup');
	jQuery('input[name=txtAdName]').live('keyup',function(){
		val = jQuery(this).val();
		prew  = jQuery(this).parents('tr.add-Group');
		prew.find('div.adName').text(val);
	});

	//create group
	jQuery('.add-Row').click(function(){
		tbl = jQuery('#myTable');
		tbody = tbl.find('tbody');
				
		newGroup = jQuery('tr.myTable:first').clone();
		newGroup.find('input[type=text]').val('dsdasdadsas');
		aboveGroup.after(newGroup);				
	});
});

</script>
<table cellspacing="0" cellpadding="0" border="0" width="99%">
  <tr class="add-Group">
    <TD>
        <form name="create_campaign" method="POST" id="create_campaign" action=""  enctype="multipart/form-data">
          <table cellspacing="0" cellpadding="0"  width="100%">
          	
                <tr>
                  <td valign="top" width="50%" style="border:#CCCCCC 1px solid;padding-left:10px;">
                  
                    <table width="100%" cellpadding="0" cellspacing="0"  >
	                     <input type="hidden" name="fid" id="fid" value="<?php echo $fid;?>">
	                     <input type="hidden" name="action" id="hidden_field" value="submit">
	                     <input type="hidden" name="enddate" value="<?php echo $_REQUEST[duration];?>">
	                     <input type="hidden" name="adspaceid" value="<?php echo $_REQUEST[id];?>">
	                     <input type="hidden" name="networkId" value="<?php echo $group->adgroup_network;?>">
	                     <input type="hidden" name="networkType" value="<?php echo $group->network_type; ?>">
 	                     <tr>
	                     	
	                     	<td colspan="2"><br><?php if($message!="") echo $message;?></td>
	                     </tr>
	                    <tr>
                           <td align="left" colspan="2" height="30">
                           <input checked="true" onclick="showhidSelectBox('none')" type="radio" name="radSelectAd" id="radSelectAd1">&nbsp;Use An existing page
                           <input onclick="showhidSelectBox('')"  type="radio" name="radSelectAd" id="radSelectAd2">&nbsp;Use a landing page</td>
                        </tr>
                       	<?php if(mysql_num_rows($sql_landing_page)>0) { ?>
				        <tr>
				        <td>&nbsp;</td>
				            <TD  id="tdExistingAd" style="display:none;height:30px;">
				               <select name="selExistingAd" id="selExistingAd" onchange="show_landingURL(this.value)" style="width:120px;">
				                 <?php while($res_landing_page= mysql_fetch_array($sql_landing_page)){ ?>
				                       <option value="<?=$GLOBALS['site_url'].$res_landing_page['pageName'].".php";?>"> <?=stripslashes($res_landing_page['pageName']);?> </option>
	                             <?php } ?>
				               </select>
                             </TD>
						</tr>
				       	<?php } else { ?>
				       		<tr>
				            <td colspan="2" id="tdExistingAd"  style="font-size:12px;font-family: times New Roman;padding-bottom:5px;padding-top:5px;">You do not have any Landing Pages. <a href="create_landing_page.php" class="register_link">Create a new Landing Page</a></td>
				           </tr>
				       	<?php } ?>
                        <tr>
                              <TD  style="font-size:12px;font-family: times New Roman;height:30px;">*Headline:</TD>
                              <td><input type="text" name="txtHeadline" value="<?php echo $_POST['txtHeadline'];?>" id="txtHeadline" onkeyup="return preview_heading();" style="width:183px;"></td>
                        </tr>
                        <?php if($group->network_type=="text"){ ?>
                        <tr>
                              <TD valign="top"  style="font-size:12px;font-family: times New Roman;height:30px;">*Add Description</TD>
                              <td> <textareA name="text_description" id="text_description" onkeyup="return preview_text_description_func();"><?php echo $_POST['text_description'];?></textareA></td>
                        </tr>
                        
                        <?php } if($group->network_type=="banner"  || $group->network_type=="thumbnail"){ ?>
                          <tr>
                              <TD colspan="2" style="font-size:12px;font-family: times New Roman;padding-top:5px;" valign="top">*Upload File: <small> (Max. 90KB) (728x90, 468x60, 120x600, 160x600, 300x250)</small></TD>
                            </tr>
                            <tr>
                            <td>&nbsp;</td>
                            	<td style="padding-top:5px;padding-bottom:5px;font-size: 12px;font-family: times New Roman;">
								<input type="file" name="file" id="file" size='13' />
								<br/>
							
                                <inpUT type="hidden" name="sahara" value="11">
                              </td>
                            </tr>
                            <?php }?>
                             <tr>
                              <TD style="font-size:12px;font-family: times New Roman;height:30px;" valign="top">*Ad Name</TD>
                              <TD style="font-size:12px;padding-top:4px;"><input type="text" name="txtAdName" value="<?php echo $_POST['txtAdName'];?>" id="txtAdName" style="width:183px;"><br>(For personal reference)</TD>
                            </tr>
                            <tr>
                              <TD style="font-size:12px;font-family: times New Roman;height:30px;" valign="top">*Destination URL:</TD>
                              <TD style="font-size:12px;padding-top:4px;"><input type="text" name="txtUrl" id="txtUrl" value="<?php echo $_POST['txtUrl'];?>" style="width:183px;"><br>example: http://example.com</TD>
                            </tr>
                           
                             <tr>
                              <TD colspan="2">&nbsp;</TD>
                            </tr>
                            <tr>
                              <TD colspan="2" align="center">
                                <input type="button" value="Cancel" name="cancel" id="cancel" onclick="return main_page();">&nbsp;
                                <input type="submit"  value="Save" name="submit"></TD>
                            </tr>
                            <tr>
                              <TD colspan="2">&nbsp;</TD>
                            </tr>
                    </table>
                  
                   </td>
                   <td width="10">&nbsp;</td>
                   <td valign="top" width="48%">
                   		<table cellpadding="0" cellspacing="0" width="100%">
                   			<tr>
                              <td align="center" id="prev_banner">
                              <?php if(!empty($banner_url)||!empty($_POST['banner_url'])):?>
								<a href='javascript:void(0)' id='prev_banner_url' target='_blank'>
									<img src='<?php echo !empty($banner_url) ? $banner_url:$_POST['banner_url'];?>' 
									width='<?php echo $sizeBanner->width? $sizeBanner->width/2.5 :300;?>' height='<?php echo $sizeBanner->height? $sizeBanner->height/2.5 :50;?>' alt='no banner'/>
								</a>
								<?php endif;?>
                              </td>
                            </tr>
                            <tr>
                              <td align="center" id="prev_heading"></td>
                            </tr>
                            <tr>
                              <td align="center" id="preview_text_description">
                              	
                              </td>
                            </tr>
                            <tr >
                              <td style="font-size:12px;font-family: times New Roman;">
                              	<div style="float:left;position:relative;top:0;width:280px;">
                              		<div id="ad-preview">
                              			<h2>Ad Preview</h2>
                              			<?php if($group->network_type=="banner"  || $group->network_type=="thumbnail"){ 
                              				echo '
                              						<div class="headline" style="width:100%;">This is a sample headline</div>
				                              		<div  class="adName" style="width:100%;">This is sample text. You get seventy characters. Have fun with them :)</div>
				                              		<div class="txtUrl" style="width:100%;">www.Sample-Site.com</div>';
                              			}else{
                              					echo '<div class="headline" style="width:100%;">This is a sample headline</div>
                              					<div class="adName" style="width:100%;"></div>
			                            		  		<div  class="adDesc" style="width:100%;">This is sample text. You get seventy characters. Have fun with them :)</div>
			                              				<div class="txtUrl" style="width:100%;">www.Sample-Site.com</div>
		                              					';
                              			}?>
                              			
			                                
		                              		 
	                              	</div>
                              	</div>
                              </td>
                            </tr>
                            <tr>
                           		<td height="50">&nbsp;</td>
                           </tr>
                           
                   		</table>
                   </td>
                </tr>
            </table>
       </form>
    </TD>
  </tr>
  <tr class="view">
  	<td colspan="3" style="padding-left:10px;"><br><br>
  	<form name="" method="POST" id="form1" action=""  enctype="multipart/form-data">
  		
  		<?php 
		$query =mysql_query("Select * FROM temp_adgroup_ad where siteuserId={$_SESSION[siteuserId]}");
		$i=1;
		if(mysql_num_rows($query)>0)
		{
			echo '<table  id="myTable"  width="600px" style="border:solid 1px #ccc;"><tbody>
  		<tr>
  			<th><input type="checkbox" id="group" name="group" onclick="Checkall();"></th>
  			<th style="font-family:Time new roman;font-size:12px;">Ad headline</th>
  			<th style="font-family:Time new roman;font-size:12px;">Ad text</th>
  			<th style="font-family:Time new roman;font-size:12px;">Destination URL</th>
  		</tr>';
			
			while($result= mysql_fetch_array($query)){
				echo '<tr>
						<td width="20" align="center"><input type="checkbox" id="ad_group_id" name="ad_group_id[]" value='.$result['id'].'></td>
						<td width="200" align="center">'.$result['heading'].'</td>
						<td width="200" align="center">'.$result['personal_reference'].'</td>
						<td align="center">'.$result['dest_url'].'</td>

					</tr>'; 
				$i++;
			}
			echo '</tbody></table>'; 
		}
		?>
		
		<br><br>
		  <table border="0" cellpadding="0" cellspacing="0" width="100%">
		  	<tr>
		  		<td align="center">
		  		<input type="submit" name="submit" value="Next">
                           		<input type="hidden" name="mode" value="step3">
                           		<input type="hidden" name="mode4" value="m4">
		  		</td>
		  	</tr>
		  </table>		
		  </form>
  	</td>
  </tr>
  </table>
<?php }?>
<script>
function Checkall(){
	
	var chkElement=document.getElementsByName("ad_group_id[]");
	
	if(document.getElementById('group').checked==true){
		for(var i=0;i<chkElement.length;i++){
			chkElement[i].checked=true;
		}
	}else{
		for(var i=0;i<chkElement.length;i++){
			chkElement[i].checked=false;
		}
	}
}
$('#form1').submit(function() {
    if (!$('input:checkbox', this).is(':checked'))
     {
    	alert('Please select something!');
        return false;
    }
    return true; 
});


</script>
	
			
	